package com.kh.samr.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回结果Dto
 *
 * @author Harry
 * @date 2020/11/24
 */
@ApiModel(description = "返回结果Dto")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultDto<T>{
	
	public ResultDto(int errcode, String errmsg) {
		this.errcode = errcode;
		this.errmsg = errmsg;
	}
	
	public ResultDto(T list) {
		this.errcode = 0;
		this.errmsg = "";
		this.list = list;
	}
	
	/**
	 * 错误码
	 */
	@ApiModelProperty(value = "错误码", readOnly = true, notes = "默认为0表示成功")
	private Integer errcode;
	
	/**
	 * 返回处理消息
	 */
	@ApiModelProperty(value = "错误信息", readOnly = true, notes = "默认为空字符串，当 errcode 不为零时返回错误信息")
	private String errmsg;
	
	/**
	 * 返回数据对象
	 */
	@ApiModelProperty(value = "返回数据对象", readOnly = true)
	private T list;
	
	/**
	 * 总记录数
	 */
	@ApiModelProperty(value = "总记录数", readOnly = true, notes = "分页使用")
	private long total;
	
}
